//
//  Map.m
//  BattleshipRevolution
//
//  Created by Duy Do Phan on 8/27/12.
//  Copyright (c) 2012 YPVN. All rights reserved.
//

#import "Map.h"

@implementation CellMap
@synthesize isFired;
@synthesize cellPosition, cellSize;

- (id)initWithSize:(CGSize)size onPosition:(CGPoint)position
{
    self = [super init];
    if (self) {
        cellSize = size;
        cellPosition = position;
        isFired = NO;
    }
    return self;
}

@end


@implementation Map
@synthesize mapSize, cellSize;
@synthesize cells;

- (void) dealloc
{
    [cells release];
    [super dealloc];
}

- (id) init {
    self = [super init];
    if (self) {
        mapSize = CGSizeMake(16, 16);
        cellSize = CGSizeMake(20, 20);
        
        int size = [self size];
        cells = [[NSMutableArray alloc] initWithCapacity:size];
        for (int i = 0; i < size; i++) {
            CGPoint position = CGPointMake(i % (int)mapSize.width, i / (int)mapSize.width);
            CellMap *cell = [[CellMap alloc] initWithSize:cellSize onPosition:position];
            [cells insertObject:cell atIndex:i];
        }
    }
    return self;
}

- (int) size
{
    return mapSize.width*mapSize.height;
}

@end
